//
//  BBENetWorkTool.swift
//  PictureShow
//
//  Created by apple on 16/4/27.
//  Copyright © 2016年 apple. All rights reserved.
/*
// 1.获取请求的URLString
let urlString = "http://mobapi.meilishuo.com/2.0/twitter/popular.json"

// 2.获取请求的参数
let parameters = ["offset" : "\(offSet)", "limit" : "30", "access_token" : "b92e0c6fd3ca919d3e7547d446d9a8c2"]
*/

import UIKit
import AFNetworking

class BBENetWorkTool: NSObject {

    static let shareNetworking = BBENetWorkTool()
    
    // 获取网络管理者
    private let manager = AFHTTPSessionManager()
    
    func requestData(urlString : String, parameter : [String : NSObject], finished : (result : AnyObject?, error : NSError?)->Void)
    {
        manager.responseSerializer.acceptableContentTypes?.insert("text/html")
     
        manager.GET(urlString, parameters: parameter, progress: nil, success: { (task : NSURLSessionDataTask, result : AnyObject?) -> Void in
            
            finished(result: result, error: nil)
            
            }) { (task : NSURLSessionDataTask?, error : NSError) -> Void in
                
                finished(result: nil, error: error)
        }
    }
}
